package com.zx.mes.hyl.rocket.mq.yml;

import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * rocket mq properties config
 *
 * @author 华云龙
 * @date 2018-12-10
 */
@Data
@Accessors(chain = true)
@ConfigurationProperties(prefix = "hyl.rocket.mq")
public class RocketMqProperties {

    @Deprecated
    /**
     * rocket mq 集群的url地址
     */
    private String nameServer;

    /**
     * rocket mq map<String,RocketMq>
     */
    private Map<String, RocketMq> map;

    /**
     * thread pool config
     */
    private RocketMqThreadPool rocketMqThreadPool = new RocketMqThreadPool();

    @Data
    @Accessors(chain = true)
    public static class RocketMq {
        /**
         * rocket mq 集群的url地址
         */
        private String nameServer;

        /**
         * rocket mq 生产者组的名称
         */
        private String producerGroupName;

        /**
         * topic of producerGroupName
         */
        private String topic;

        /**
         * tags of producerGroupName
         */
        private String tags;

        /**
         * keys of producerGroupName
         */
        private String keys;

        /**
         * rocket mq retry consume times
         */
        private int consumeRetryTimes = 2;

        /**
         * rocket mq retry send times
         */
        private int sendRetryTimes = 2;

        /**
         * rocket mq consume thread min
         */
        private int consumeThreadMin = 2;

        /**
         * rocket mq consume thread max
         */
        private int consumeThreadMax = 20;
    }

    /**
     * 静态内部类
     * rocket mq 需要使用的线程池配置信息
     */
    @Data
    @Accessors(chain = true)
    public static class RocketMqThreadPool {

        private int corePoolSize = 2;

        private int maximumPoolSize = 5;

        private long keepAliveTime = 100;

        private TimeUnit unit = TimeUnit.SECONDS;

        /**
         * arrayBlockingQueueCapacity
         * example 2000
         */
        private int arrayBlockingQueueCapacity = 2000;
    }
}
